/*
 * @Author: Robin
 * @Date: 2020-12-02 17:37:26
 * @LastEditors: Robin
 * @LastEditTime: 2020-12-02 17:46:01
 * @Description: Description
 */
package main

import (
	"fmt"

	uuid "github.com/satori/go.uuid"
)

func main() {
	// Creating UUID Version 4
	// panic on error
	u1 := uuid.NewV1()
	fmt.Printf("UUIDv1: %s\n", u1)
	u3 := uuid.NewV3(uuid.NewV1(), "hello")
	fmt.Printf("UUIDv3: %s\n", u3)
	u4 := uuid.NewV4()
	fmt.Printf("UUIDv4: %s\n", u4)

	// or error handling
	// u2 := uuid.NewV4()
	// if err != nil {
	// 	fmt.Printf("Something went wrong: %s", err)
	// 	return
	// }
	// fmt.Printf("UUIDv4: %s\n", u2)

	// Parsing UUID from string input
	us2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
	if err != nil {
		fmt.Printf("Something went wrong: %s\n", err)
		return
	}
	fmt.Printf("Successfully parsed: %s\n", us2)
	fmt.Println("UUID Version:", us2.Version())
}
